import 'package:flutter/material.dart';
import 'package:zrjz/comm/constants/constants.dart';

/// 自定义Loading的UI展示
class CustomLoadingWidget extends StatelessWidget {
  const CustomLoadingWidget({
    Key? key,
    required this.msg,
  }) : super(key: key);

  final String msg;

  @override
  Widget build(BuildContext context) {
    return _buildBg(children: [
      const SizedBox(
        width: 30,
        height: 30,
        child: CircularProgressIndicator(
          strokeWidth: 2,
          valueColor: AlwaysStoppedAnimation(Colors.white),
        ),
      ),
      Container(
        margin: const EdgeInsets.only(top: 12),
        child: Text(
          msg,
          style: const TextStyle(color: Colors.white, fontSize: 13),
          textAlign: TextAlign.center,
        ),
      ),
    ]);
  }

  Widget _buildBg({required List<Widget> children}) {
    return Container(
      width: 85,
      height: 85,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: DarkThemeUtil.multiColors(const Color(0xcc000000),darkColor: ColorConstants.darkBlackItem),
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(mainAxisSize: MainAxisSize.min, children: children),
    );
  }
}
